﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;

using Frame.Lib.Core.Base;

namespace Jzy.Workflow.Flow
{
    public class ControlRightDAL : BaseDAL
    {
        public void Delete(string controlName, int nodeID, int rightID)
        {
            string sql = "delete from " + WFTableName.FlowControlRight + " where ControlName = @p0 and NodeID=@p1 and RightID=@p2";
            dbOper.RunSql(sql, controlName, nodeID, rightID);
        }

        internal List<ControlRightInfo> GetList(int flowID, string controlName)
        {
            string sql = "select * from " + WFTableName.FlowControlRight + " where FlowID=@p0 and ControlName = @p1";
            List<ControlRightInfo> list = dbOper.Query<ControlRightInfo>(sql, flowID, controlName);
            return list;
        }

        internal List<string> GetControls(int nodeID,int userID, RightName rightName)
        {
            string sql = "select ControlName from " + WFTableName.FlowControlRight  + " where NodeID=@p0 and UserID=@p1 and RightID=" + (int)rightName;
            List<string> ctls = dbOper.Query<string>(sql, nodeID, userID);
            return ctls;
        }
    }

}
